<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>todo &mdash; GOZERWAVE v0.1 BETA documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '0.1 BETA',
        COLLAPSE_MODINDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="top" title="GOZERWAVE v0.1 BETA documentation" href="../index.html" />
    <link rel="next" title="wikipedia" href="wikipedia.html" />
    <link rel="prev" title="rss" href="rss.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../modindex.html" title="Global Module Index"
             accesskey="M">modules</a> |</li>
        <li class="right" >
          <a href="wikipedia.html" title="wikipedia"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="rss.html" title="rss"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">GOZERWAVE v0.1 BETA documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="todo">
<h1>todo<a class="headerlink" href="#todo" title="Permalink to this headline">¶</a></h1>
<div class="section" id="module-waveplugs.todo">
<h2>description<a class="headerlink" href="#module-waveplugs.todo" title="Permalink to this headline">¶</a></h2>
<p>manage todo lists .. by user or by channel .. a time/data string can 
be provided to set time on a todo item.</p>
<dl class="class">
<dt id="waveplugs.todo.GAETodo">
<em class="property">class </em><tt class="descclassname">waveplugs.todo.</tt><tt class="descname">GAETodo</tt><big>(</big><em>parent=None</em>, <em>key_name=None</em>, <em>_app=None</em>, <em>**kwds</em><big>)</big><a class="headerlink" href="#waveplugs.todo.GAETodo" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref docutils literal"><span class="pre">google.appengine.ext.db.Expando</span></tt></p>
<dl class="attribute">
<dt id="waveplugs.todo.GAETodo.descr">
<tt class="descname">descr</tt><a class="headerlink" href="#waveplugs.todo.GAETodo.descr" title="Permalink to this definition">¶</a></dt>
<dd>A textual property, which can be multi- or single-line.</dd></dl>

<dl class="attribute">
<dt id="waveplugs.todo.GAETodo.duration">
<tt class="descname">duration</tt><a class="headerlink" href="#waveplugs.todo.GAETodo.duration" title="Permalink to this definition">¶</a></dt>
<dd>An integer property.</dd></dl>

<dl class="attribute">
<dt id="waveplugs.todo.GAETodo.indx">
<tt class="descname">indx</tt><a class="headerlink" href="#waveplugs.todo.GAETodo.indx" title="Permalink to this definition">¶</a></dt>
<dd>An integer property.</dd></dl>

<dl class="attribute">
<dt id="waveplugs.todo.GAETodo.name">
<tt class="descname">name</tt><a class="headerlink" href="#waveplugs.todo.GAETodo.name" title="Permalink to this definition">¶</a></dt>
<dd>A textual property, which can be multi- or single-line.</dd></dl>

<dl class="attribute">
<dt id="waveplugs.todo.GAETodo.priority">
<tt class="descname">priority</tt><a class="headerlink" href="#waveplugs.todo.GAETodo.priority" title="Permalink to this definition">¶</a></dt>
<dd>An integer property.</dd></dl>

<dl class="attribute">
<dt id="waveplugs.todo.GAETodo.time">
<tt class="descname">time</tt><a class="headerlink" href="#waveplugs.todo.GAETodo.time" title="Permalink to this definition">¶</a></dt>
<dd>A date property, which stores a date without a time.</dd></dl>

<dl class="attribute">
<dt id="waveplugs.todo.GAETodo.warnsec">
<tt class="descname">warnsec</tt><a class="headerlink" href="#waveplugs.todo.GAETodo.warnsec" title="Permalink to this definition">¶</a></dt>
<dd>An integer property.</dd></dl>

</dd></dl>

<dl class="class">
<dt id="waveplugs.todo.GAETodoDb">
<em class="property">class </em><tt class="descclassname">waveplugs.todo.</tt><tt class="descname">GAETodoDb</tt><a class="headerlink" href="#waveplugs.todo.GAETodoDb" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a title="(in Python v2.7)" class="reference external" href="http://docs.python.org/dev/library/functions.html#object"><tt class="xref docutils literal"><span class="pre">object</span></tt></a></p>
<p>database todo interface</p>
<dl class="method">
<dt id="waveplugs.todo.GAETodoDb.add">
<tt class="descname">add</tt><big>(</big><em>name</em>, <em>txt</em>, <em>ttime=0</em>, <em>duration=0</em>, <em>warnsec=0</em>, <em>priority=0</em>, <em>alarmnr=None</em><big>)</big><a class="headerlink" href="#waveplugs.todo.GAETodoDb.add" title="Permalink to this definition">¶</a></dt>
<dd>add a todo</dd></dl>

<dl class="method">
<dt id="waveplugs.todo.GAETodoDb.delete">
<tt class="descname">delete</tt><big>(</big><em>name</em>, <em>indexnr</em><big>)</big><a class="headerlink" href="#waveplugs.todo.GAETodoDb.delete" title="Permalink to this definition">¶</a></dt>
<dd>delete todo item</dd></dl>

<dl class="method">
<dt id="waveplugs.todo.GAETodoDb.get">
<tt class="descname">get</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#waveplugs.todo.GAETodoDb.get" title="Permalink to this definition">¶</a></dt>
<dd>get todo list of &lt;name&gt;</dd></dl>

<dl class="method">
<dt id="waveplugs.todo.GAETodoDb.getid">
<tt class="descname">getid</tt><big>(</big><em>name</em>, <em>idnr</em><big>)</big><a class="headerlink" href="#waveplugs.todo.GAETodoDb.getid" title="Permalink to this definition">¶</a></dt>
<dd>get todo data of &lt;idnr&gt;</dd></dl>

<dl class="method">
<dt id="waveplugs.todo.GAETodoDb.getprio">
<tt class="descname">getprio</tt><big>(</big><em>name</em>, <em>todonr</em><big>)</big><a class="headerlink" href="#waveplugs.todo.GAETodoDb.getprio" title="Permalink to this definition">¶</a></dt>
<dd>get priority of todonr</dd></dl>

<dl class="method">
<dt id="waveplugs.todo.GAETodoDb.getwarnsec">
<tt class="descname">getwarnsec</tt><big>(</big><em>todonr</em><big>)</big><a class="headerlink" href="#waveplugs.todo.GAETodoDb.getwarnsec" title="Permalink to this definition">¶</a></dt>
<dd>get priority of todonr</dd></dl>

<dl class="method">
<dt id="waveplugs.todo.GAETodoDb.reset">
<tt class="descname">reset</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#waveplugs.todo.GAETodoDb.reset" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="waveplugs.todo.GAETodoDb.setprio">
<tt class="descname">setprio</tt><big>(</big><em>who</em>, <em>todonr</em>, <em>prio</em><big>)</big><a class="headerlink" href="#waveplugs.todo.GAETodoDb.setprio" title="Permalink to this definition">¶</a></dt>
<dd>set priority of todonr</dd></dl>

<dl class="method">
<dt id="waveplugs.todo.GAETodoDb.settime">
<tt class="descname">settime</tt><big>(</big><em>who</em>, <em>todonr</em>, <em>ttime</em><big>)</big><a class="headerlink" href="#waveplugs.todo.GAETodoDb.settime" title="Permalink to this definition">¶</a></dt>
<dd>set time of todonr</dd></dl>

<dl class="method">
<dt id="waveplugs.todo.GAETodoDb.size">
<tt class="descname">size</tt><big>(</big><big>)</big><a class="headerlink" href="#waveplugs.todo.GAETodoDb.size" title="Permalink to this definition">¶</a></dt>
<dd>return number of todo&#8217;s</dd></dl>

<dl class="method">
<dt id="waveplugs.todo.GAETodoDb.timetodo">
<tt class="descname">timetodo</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#waveplugs.todo.GAETodoDb.timetodo" title="Permalink to this definition">¶</a></dt>
<dd>show all time related todoos.</dd></dl>

<dl class="method">
<dt id="waveplugs.todo.GAETodoDb.toolate">
<tt class="descname">toolate</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#waveplugs.todo.GAETodoDb.toolate" title="Permalink to this definition">¶</a></dt>
<dd>show if there are any time related todoos that are too late</dd></dl>

<dl class="method">
<dt id="waveplugs.todo.GAETodoDb.withintime">
<tt class="descname">withintime</tt><big>(</big><em>name</em>, <em>time1</em>, <em>time2</em><big>)</big><a class="headerlink" href="#waveplugs.todo.GAETodoDb.withintime" title="Permalink to this definition">¶</a></dt>
<dd>show todo list within time frame</dd></dl>

</dd></dl>

<dl class="function">
<dt id="waveplugs.todo.handle_chantodo">
<tt class="descclassname">waveplugs.todo.</tt><tt class="descname">handle_chantodo</tt><big>(</big><em>bot</em>, <em>ievent</em><big>)</big><a class="headerlink" href="#waveplugs.todo.handle_chantodo" title="Permalink to this definition">¶</a></dt>
<dd>todo-chan [&lt;item&gt;] .. show channel todo&#8217;s or set todo item for         channel.</dd></dl>

<dl class="function">
<dt id="waveplugs.todo.handle_chantodo2">
<tt class="descclassname">waveplugs.todo.</tt><tt class="descname">handle_chantodo2</tt><big>(</big><em>bot</em>, <em>ievent</em><big>)</big><a class="headerlink" href="#waveplugs.todo.handle_chantodo2" title="Permalink to this definition">¶</a></dt>
<dd>set todo item for channel.</dd></dl>

<dl class="function">
<dt id="waveplugs.todo.handle_getpriority">
<tt class="descclassname">waveplugs.todo.</tt><tt class="descname">handle_getpriority</tt><big>(</big><em>bot</em>, <em>ievent</em><big>)</big><a class="headerlink" href="#waveplugs.todo.handle_getpriority" title="Permalink to this definition">¶</a></dt>
<dd>todo-getprio &lt;[channel|name]&gt; &lt;itemnr&gt; .. get priority of todo         item.</dd></dl>

<dl class="function">
<dt id="waveplugs.todo.handle_gettodo">
<tt class="descclassname">waveplugs.todo.</tt><tt class="descname">handle_gettodo</tt><big>(</big><em>bot</em>, <em>ievent</em><big>)</big><a class="headerlink" href="#waveplugs.todo.handle_gettodo" title="Permalink to this definition">¶</a></dt>
<dd>todo-get &lt;nick&gt; .. get todo of another user.</dd></dl>

<dl class="function">
<dt id="waveplugs.todo.handle_setpriority">
<tt class="descclassname">waveplugs.todo.</tt><tt class="descname">handle_setpriority</tt><big>(</big><em>bot</em>, <em>ievent</em><big>)</big><a class="headerlink" href="#waveplugs.todo.handle_setpriority" title="Permalink to this definition">¶</a></dt>
<dd>todo-setprio [&lt;channel|name&gt;] &lt;itemnr&gt; &lt;prio&gt; .. show priority         on todo item.</dd></dl>

<dl class="function">
<dt id="waveplugs.todo.handle_settodo">
<tt class="descclassname">waveplugs.todo.</tt><tt class="descname">handle_settodo</tt><big>(</big><em>bot</em>, <em>ievent</em><big>)</big><a class="headerlink" href="#waveplugs.todo.handle_settodo" title="Permalink to this definition">¶</a></dt>
<dd>todo-set &lt;name&gt; &lt;txt&gt; .. add a todo to another user&#8217;s todo list.</dd></dl>

<dl class="function">
<dt id="waveplugs.todo.handle_today">
<tt class="descclassname">waveplugs.todo.</tt><tt class="descname">handle_today</tt><big>(</big><em>bot</em>, <em>ievent</em><big>)</big><a class="headerlink" href="#waveplugs.todo.handle_today" title="Permalink to this definition">¶</a></dt>
<dd>todo-today .. show time related todo items for today.</dd></dl>

<dl class="function">
<dt id="waveplugs.todo.handle_todo">
<tt class="descclassname">waveplugs.todo.</tt><tt class="descname">handle_todo</tt><big>(</big><em>bot</em>, <em>ievent</em><big>)</big><a class="headerlink" href="#waveplugs.todo.handle_todo" title="Permalink to this definition">¶</a></dt>
<dd>todo [&lt;item&gt;] .. show todo&#8217;s or set todo item .. a time/date can be         given.</dd></dl>

<dl class="function">
<dt id="waveplugs.todo.handle_todo2">
<tt class="descclassname">waveplugs.todo.</tt><tt class="descname">handle_todo2</tt><big>(</big><em>bot</em>, <em>ievent</em><big>)</big><a class="headerlink" href="#waveplugs.todo.handle_todo2" title="Permalink to this definition">¶</a></dt>
<dd>set todo item</dd></dl>

<dl class="function">
<dt id="waveplugs.todo.handle_todochandone">
<tt class="descclassname">waveplugs.todo.</tt><tt class="descname">handle_todochandone</tt><big>(</big><em>bot</em>, <em>ievent</em><big>)</big><a class="headerlink" href="#waveplugs.todo.handle_todochandone" title="Permalink to this definition">¶</a></dt>
<dd>todo-chandone &lt;listofnrs&gt; .. remove channel todo item.</dd></dl>

<dl class="function">
<dt id="waveplugs.todo.handle_tododone">
<tt class="descclassname">waveplugs.todo.</tt><tt class="descname">handle_tododone</tt><big>(</big><em>bot</em>, <em>ievent</em><big>)</big><a class="headerlink" href="#waveplugs.todo.handle_tododone" title="Permalink to this definition">¶</a></dt>
<dd>todo-done &lt;listofnrs&gt; .. remove todo items</dd></dl>

<dl class="function">
<dt id="waveplugs.todo.handle_todosettime">
<tt class="descclassname">waveplugs.todo.</tt><tt class="descname">handle_todosettime</tt><big>(</big><em>bot</em>, <em>ievent</em><big>)</big><a class="headerlink" href="#waveplugs.todo.handle_todosettime" title="Permalink to this definition">¶</a></dt>
<dd>todo-settime [&lt;channel|name&gt;] &lt;itemnr&gt; &lt;timestring&gt; .. set time         on todo item.</dd></dl>

<dl class="function">
<dt id="waveplugs.todo.handle_todotime">
<tt class="descclassname">waveplugs.todo.</tt><tt class="descname">handle_todotime</tt><big>(</big><em>bot</em>, <em>ievent</em><big>)</big><a class="headerlink" href="#waveplugs.todo.handle_todotime" title="Permalink to this definition">¶</a></dt>
<dd>todo-time .. show time related todoos.</dd></dl>

<dl class="function">
<dt id="waveplugs.todo.handle_todoweek">
<tt class="descclassname">waveplugs.todo.</tt><tt class="descname">handle_todoweek</tt><big>(</big><em>bot</em>, <em>ievent</em><big>)</big><a class="headerlink" href="#waveplugs.todo.handle_todoweek" title="Permalink to this definition">¶</a></dt>
<dd>todo-week .. show time related todo items for this week.</dd></dl>

<dl class="function">
<dt id="waveplugs.todo.handle_tomorrow">
<tt class="descclassname">waveplugs.todo.</tt><tt class="descname">handle_tomorrow</tt><big>(</big><em>bot</em>, <em>ievent</em><big>)</big><a class="headerlink" href="#waveplugs.todo.handle_tomorrow" title="Permalink to this definition">¶</a></dt>
<dd>todo-tomorrow .. show time related todo items for tomorrow.</dd></dl>

<dl class="function">
<dt id="waveplugs.todo.saytodo">
<tt class="descclassname">waveplugs.todo.</tt><tt class="descname">saytodo</tt><big>(</big><em>bot</em>, <em>ievent</em>, <em>todoos</em><big>)</big><a class="headerlink" href="#waveplugs.todo.saytodo" title="Permalink to this definition">¶</a></dt>
<dd>output todo items of &lt;name&gt;.</dd></dl>

<dl class="function">
<dt id="waveplugs.todo.size">
<tt class="descclassname">waveplugs.todo.</tt><tt class="descname">size</tt><big>(</big><big>)</big><a class="headerlink" href="#waveplugs.todo.size" title="Permalink to this definition">¶</a></dt>
<dd>return number of todo entries</dd></dl>

</div>
<div class="section" id="code">
<h2>code<a class="headerlink" href="#code" title="Permalink to this headline">¶</a></h2>
<div class="highlight-python"><table class="highlighttable"><tr><td class="linenos"><pre>  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701</pre></td><td class="code"><div class="highlight"><pre><span class="c"># waveplugs/todo.py</span>
<span class="c">#</span>
<span class="c">#</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    manage todo lists .. by user or by channel .. a time/data string can </span>
<span class="sd">    be provided to set time on a todo item.</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="c">## gozerlib imports</span>

<span class="kn">from</span> <span class="nn">gozerlib.utils.exception</span> <span class="kn">import</span> <span class="n">handle_exception</span>
<span class="kn">from</span> <span class="nn">gozerlib.commands</span> <span class="kn">import</span> <span class="n">cmnds</span>
<span class="kn">from</span> <span class="nn">gozerlib.examples</span> <span class="kn">import</span> <span class="n">examples</span>
<span class="kn">from</span> <span class="nn">gozerlib.aliases</span> <span class="kn">import</span> <span class="n">aliasset</span>
<span class="kn">from</span> <span class="nn">gozerlib.users</span> <span class="kn">import</span> <span class="n">byname</span>
<span class="kn">from</span> <span class="nn">gozerlib.utils.timeutils</span> <span class="kn">import</span> <span class="n">strtotime</span><span class="p">,</span> <span class="n">today</span><span class="p">,</span> <span class="n">striptime</span>

<span class="c">## google imports</span>

<span class="kn">from</span> <span class="nn">google.appengine.ext</span> <span class="kn">import</span> <span class="n">db</span>

<span class="c">## generic import</span>

<span class="kn">from</span> <span class="nn">datetime</span> <span class="kn">import</span> <span class="n">datetime</span><span class="p">,</span> <span class="n">timedelta</span>
<span class="kn">from</span> <span class="nn">time</span> <span class="kn">import</span> <span class="n">localtime</span>
<span class="kn">import</span> <span class="nn">time</span>
<span class="kn">import</span> <span class="nn">thread</span>
<span class="kn">import</span> <span class="nn">os</span>

<span class="c">## MODEL</span>

<span class="k">class</span> <span class="nc">GAETodo</span><span class="p">(</span><span class="n">db</span><span class="o">.</span><span class="n">Expando</span><span class="p">):</span>

    <span class="n">indx</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">IntegerProperty</span><span class="p">()</span>
    <span class="n">name</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">StringProperty</span><span class="p">(</span><span class="n">required</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
    <span class="n">time</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">DateProperty</span><span class="p">()</span>
    <span class="n">duration</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">IntegerProperty</span><span class="p">()</span>
    <span class="n">warnsec</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">IntegerProperty</span><span class="p">()</span>
    <span class="n">descr</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">StringProperty</span><span class="p">(</span><span class="n">required</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
    <span class="n">priority</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">IntegerProperty</span><span class="p">()</span>

<span class="c">## todo class</span>

<span class="k">class</span> <span class="nc">GAETodoDb</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot; database todo interface &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="nf">reset</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span> 
        <span class="k">pass</span>

    <span class="k">def</span> <span class="nf">size</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot; return number of todo&#39;s &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="mf">0</span>
        
    <span class="k">def</span> <span class="nf">get</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot; get todo list of &lt;name&gt; &quot;&quot;&quot;</span>

        <span class="n">result</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">GqlQuery</span><span class="p">(</span><span class="s">&quot;SELECT * FROM GAETodo WHERE name = :1&quot;</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span><span class="o">.</span><span class="n">fetch</span><span class="p">(</span><span class="mf">1000</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">result</span>

    <span class="k">def</span> <span class="nf">getid</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">idnr</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot; get todo data of &lt;idnr&gt; &quot;&quot;&quot;</span>

        <span class="n">result</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">GqlQuery</span><span class="p">(</span><span class="s">&quot;SELECT * FROM GAETodo WHERE name = :1&quot;</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span><span class="o">.</span><span class="n">fetch</span><span class="p">(</span><span class="mf">1000</span><span class="p">)</span>

        <span class="k">for</span> <span class="n">res</span> <span class="ow">in</span> <span class="n">result</span><span class="p">:</span>
             <span class="k">if</span> <span class="n">res</span><span class="o">.</span><span class="n">key</span><span class="p">()</span><span class="o">.</span><span class="n">id</span><span class="p">()</span> <span class="o">==</span> <span class="n">idnr</span><span class="p">:</span>
                 <span class="k">return</span> <span class="n">res</span>


    <span class="k">def</span> <span class="nf">setprio</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">who</span><span class="p">,</span> <span class="n">todonr</span><span class="p">,</span> <span class="n">prio</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot; set priority of todonr &quot;&quot;&quot;</span>

        <span class="n">todo</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">getid</span><span class="p">(</span><span class="n">who</span><span class="p">,</span> <span class="n">todonr</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">todo</span><span class="p">:</span>
            <span class="n">todo</span><span class="o">.</span><span class="n">priority</span> <span class="o">=</span> <span class="n">prio</span>
            <span class="n">todo</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
            <span class="k">return</span> <span class="mf">1</span>

    <span class="k">def</span> <span class="nf">getprio</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">todonr</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot; get priority of todonr &quot;&quot;&quot;</span>

        <span class="n">todo</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">getid</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">todonr</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">todo</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">todo</span><span class="o">.</span><span class="n">priority</span>

    <span class="k">def</span> <span class="nf">getwarnsec</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">todonr</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; get priority of todonr &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="mf">0</span>

    <span class="k">def</span> <span class="nf">settime</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">who</span><span class="p">,</span> <span class="n">todonr</span><span class="p">,</span> <span class="n">ttime</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot; set time of todonr &quot;&quot;&quot;</span>

        <span class="n">todo</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">getid</span><span class="p">(</span><span class="n">who</span><span class="p">,</span> <span class="n">todonr</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">todo</span><span class="p">:</span>
            <span class="n">todo</span><span class="o">.</span><span class="n">time</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">fromtimestamp</span><span class="p">(</span><span class="n">ttime</span><span class="p">)</span>
            <span class="n">todo</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
            <span class="k">return</span> <span class="mf">1</span>

    <span class="k">def</span> <span class="nf">add</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">txt</span><span class="p">,</span> <span class="n">ttime</span><span class="o">=</span><span class="mf">0</span><span class="p">,</span> <span class="n">duration</span><span class="o">=</span><span class="mf">0</span><span class="p">,</span> <span class="n">warnsec</span><span class="o">=</span><span class="mf">0</span><span class="p">,</span> <span class="n">priority</span><span class="o">=</span><span class="mf">0</span><span class="p">,</span> <span class="n">alarmnr</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot; add a todo &quot;&quot;&quot;</span>

        <span class="n">name</span> <span class="o">=</span> <span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span>
        <span class="n">txt</span> <span class="o">=</span> <span class="n">txt</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
        <span class="n">todo</span> <span class="o">=</span> <span class="n">GAETodo</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">name</span><span class="p">,</span> <span class="n">descr</span><span class="o">=</span><span class="n">txt</span><span class="p">)</span>
        <span class="n">todo</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">name</span>
        <span class="n">todo</span><span class="o">.</span><span class="n">descr</span> <span class="o">=</span> <span class="n">txt</span>
        <span class="n">todo</span><span class="o">.</span><span class="n">ttime</span> <span class="o">=</span> <span class="n">ttime</span>
        <span class="n">todo</span><span class="o">.</span><span class="n">duration</span> <span class="o">=</span> <span class="n">duration</span>
        <span class="n">todo</span><span class="o">.</span><span class="n">warnsec</span> <span class="o">=</span> <span class="n">warnsec</span>
        <span class="n">todo</span><span class="o">.</span><span class="n">priority</span> <span class="o">=</span> <span class="n">priority</span>
        <span class="n">todo</span><span class="o">.</span><span class="n">alarmnr</span> <span class="o">=</span> <span class="n">alarmnr</span>
        <span class="n">todo</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">todo</span><span class="o">.</span><span class="n">key</span><span class="p">()</span><span class="o">.</span><span class="n">id</span><span class="p">()</span>

    <span class="k">def</span> <span class="nf">delete</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">indexnr</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot; delete todo item &quot;&quot;&quot;</span>

        <span class="n">name</span> <span class="o">=</span> <span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span>
        <span class="n">items</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">GqlQuery</span><span class="p">(</span><span class="s">&quot;SELECT * FROM GAETodo WHERE name = :1&quot;</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span><span class="o">.</span><span class="n">fetch</span><span class="p">(</span><span class="mf">1000</span><span class="p">)</span>
        <span class="n">got</span> <span class="o">=</span> <span class="mf">0</span>

        <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">items</span><span class="p">:</span>
             <span class="k">if</span> <span class="n">item</span><span class="o">.</span><span class="n">key</span><span class="p">()</span><span class="o">.</span><span class="n">id</span><span class="p">()</span> <span class="o">==</span> <span class="n">indexnr</span><span class="p">:</span>
                 <span class="n">item</span><span class="o">.</span><span class="n">delete</span><span class="p">()</span>
                 <span class="n">got</span> <span class="o">+=</span> <span class="mf">1</span>

        <span class="k">return</span> <span class="n">got</span>

    <span class="k">def</span> <span class="nf">toolate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot; show if there are any time related todoos that are too late &quot;&quot;&quot;</span>

        <span class="n">items</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">GqlQuery</span><span class="p">(</span><span class="s">&quot;SELECT * FROM GAETodo WHERE name = :1 AND time &lt; :2&quot;</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">())</span><span class="o">.</span><span class="n">all</span><span class="p">()</span>

        <span class="k">return</span> <span class="n">items</span>

    <span class="k">def</span> <span class="nf">withintime</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">time1</span><span class="p">,</span> <span class="n">time2</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot; show todo list within time frame &quot;&quot;&quot;</span>

        <span class="n">name</span> <span class="o">=</span> <span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span>
        <span class="n">items</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">GqlQuery</span><span class="p">(</span><span class="s">&quot;SELECT * FROM GAETodo WHERE name = :1 AND time &gt; :2 AND time &lt; :3&quot;</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">time1</span><span class="p">,</span> <span class="n">time2</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">()</span>

        <span class="k">return</span> <span class="n">items</span>

    <span class="k">def</span> <span class="nf">timetodo</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot; show all time related todoos. &quot;&quot;&quot;</span>

        <span class="n">name</span> <span class="o">=</span> <span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span>
        <span class="n">items</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">GqlQuery</span><span class="p">(</span><span class="s">&quot;SELECT * FROM GAETodo WHERE name = :1 AND time &gt; :2&quot;</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">datetime</span><span class="o">.</span><span class="n">min</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">()</span>

        <span class="k">return</span> <span class="n">items</span>

<span class="n">todo</span> <span class="o">=</span> <span class="n">GAETodoDb</span><span class="p">()</span>

<span class="k">assert</span><span class="p">(</span><span class="n">todo</span><span class="p">)</span>

<span class="k">def</span> <span class="nf">size</span><span class="p">():</span>

    <span class="sd">&quot;&quot;&quot; return number of todo entries &quot;&quot;&quot;</span>

    <span class="k">return</span> <span class="n">todo</span><span class="o">.</span><span class="n">size</span><span class="p">()</span>


<span class="k">def</span> <span class="nf">handle_todo</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot; </span>
<span class="sd">        todo [&lt;item&gt;] .. show todo&#39;s or set todo item .. a time/date can be \</span>
<span class="sd">        given.</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">ievent</span><span class="o">.</span><span class="n">args</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mf">0</span><span class="p">:</span>
        <span class="n">handle_todo2</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="n">name</span> <span class="o">=</span> <span class="n">ievent</span><span class="o">.</span><span class="n">auth</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">name</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&quot;can&#39;t find username for </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="n">ievent</span><span class="o">.</span><span class="n">userhost</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="k">try</span><span class="p">:</span>
        <span class="n">todoos</span> <span class="o">=</span> <span class="n">todo</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>
    <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;i dont have todo info for </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">user</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="n">saytodo</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">,</span> <span class="n">todoos</span><span class="p">)</span>

<span class="k">def</span> <span class="nf">handle_todo2</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot; set todo item &quot;&quot;&quot;</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">ievent</span><span class="o">.</span><span class="n">rest</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">missing</span><span class="p">(</span><span class="s">&quot;&lt;what&gt;&quot;</span><span class="p">)</span>
        <span class="k">return</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="n">what</span> <span class="o">=</span> <span class="n">ievent</span><span class="o">.</span><span class="n">rest</span>

    <span class="n">name</span> <span class="o">=</span> <span class="n">ievent</span><span class="o">.</span><span class="n">auth</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">name</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&quot;can&#39;t find username for </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="n">ievent</span><span class="o">.</span><span class="n">userhost</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="n">ttime</span> <span class="o">=</span> <span class="n">strtotime</span><span class="p">(</span><span class="n">what</span><span class="p">)</span>
    <span class="n">nr</span> <span class="o">=</span> <span class="mf">0</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">ttime</span> <span class="o">==</span> <span class="bp">None</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;time detected &#39;</span> <span class="o">+</span> <span class="n">time</span><span class="o">.</span><span class="n">ctime</span><span class="p">(</span><span class="n">ttime</span><span class="p">))</span>
        <span class="n">nr</span> <span class="o">=</span> <span class="n">todo</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">what</span><span class="p">,</span> <span class="n">ttime</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="n">nr</span> <span class="o">=</span> <span class="n">todo</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">what</span><span class="p">)</span>

    <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;todo </span><span class="si">%s</span><span class="s"> added&#39;</span> <span class="o">%</span> <span class="n">nr</span><span class="p">)</span>

<span class="n">cmnds</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo&#39;</span><span class="p">,</span> <span class="n">handle_todo</span><span class="p">,</span> <span class="s">&#39;USER&#39;</span><span class="p">)</span>
<span class="n">examples</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo&#39;</span><span class="p">,</span> <span class="s">&#39;todo [&lt;item&gt;] .. show todo items or add a todo item&#39;</span><span class="p">,</span> \
<span class="s">&#39;1) todo 2) todo program the bot 3) todo 22:00 sleep&#39;</span><span class="p">)</span>
<span class="c">#tests.add(&#39;todo program the bot&#39;).add(&#39;todo&#39;, &#39;program the bot&#39;)</span>

<span class="k">def</span> <span class="nf">handle_tododone</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot; todo-done &lt;listofnrs&gt; .. remove todo items &quot;&quot;&quot;</span>

    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">ievent</span><span class="o">.</span><span class="n">args</span><span class="p">)</span> <span class="o">==</span> <span class="mf">0</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">missing</span><span class="p">(</span><span class="s">&#39;&lt;list of nrs&gt;&#39;</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="k">try</span><span class="p">:</span>
        <span class="n">nrs</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">ievent</span><span class="o">.</span><span class="n">args</span><span class="p">:</span>
            <span class="n">nrs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">i</span><span class="p">))</span>
    <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> is not an integer&#39;</span> <span class="o">%</span> <span class="n">i</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="n">name</span> <span class="o">=</span> <span class="n">ievent</span><span class="o">.</span><span class="n">auth</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">name</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&quot;can&#39;t find username for </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="n">ievent</span><span class="o">.</span><span class="n">userhost</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="n">nrdone</span> <span class="o">=</span> <span class="mf">0</span>
    <span class="n">failed</span> <span class="o">=</span> <span class="p">[]</span>

    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">nrs</span><span class="p">:</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="n">todo</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span>
            <span class="n">nrdone</span> <span class="o">+=</span> <span class="mf">1</span>
        <span class="k">except</span> <span class="ne">Exception</span><span class="p">,</span> <span class="n">ex</span><span class="p">:</span>
            <span class="n">failed</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">))</span>
            <span class="n">handle_exception</span><span class="p">()</span>

    <span class="k">if</span> <span class="n">failed</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;failed to delete </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="s">&#39; .. &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">failed</span><span class="p">))</span>

    <span class="k">if</span> <span class="n">nrdone</span> <span class="o">==</span> <span class="mf">1</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> item deleted&#39;</span> <span class="o">%</span> <span class="n">nrdone</span><span class="p">)</span>
    <span class="k">elif</span> <span class="n">nrdone</span> <span class="o">==</span> <span class="mf">0</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;no items deleted&#39;</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> items deleted&#39;</span> <span class="o">%</span> <span class="n">nrdone</span><span class="p">)</span>

<span class="n">cmnds</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo-done&#39;</span><span class="p">,</span> <span class="n">handle_tododone</span><span class="p">,</span> <span class="s">&#39;USER&#39;</span><span class="p">)</span>
<span class="n">examples</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo-done&#39;</span><span class="p">,</span> <span class="s">&#39;todo-done &lt;listofnrs&gt; .. remove items from </span><span class="se">\</span>
<span class="s">todo list&#39;</span><span class="p">,</span> <span class="s">&#39;1) todo-done 1 2) todo-done 3 5 8&#39;</span><span class="p">)</span>
<span class="n">aliasset</span><span class="p">(</span><span class="s">&#39;done&#39;</span><span class="p">,</span> <span class="s">&#39;todo-done&#39;</span><span class="p">)</span>
<span class="c">#tests.add(&#39;todo program the bot&#39;, &#39;todo item (\d+) added&#39;).add(&#39;todo-done %s&#39;, &#39;(\d+) item deleted&#39;)</span>

<span class="k">def</span> <span class="nf">handle_chantodo</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        todo-chan [&lt;item&gt;] .. show channel todo&#39;s or set todo item for \</span>
<span class="sd">        channel.</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="n">ievent</span><span class="o">.</span><span class="n">rest</span><span class="p">:</span>
        <span class="n">handle_chantodo2</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="n">todoos</span> <span class="o">=</span> <span class="n">todo</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">ievent</span><span class="o">.</span><span class="n">channel</span><span class="p">)</span>
    <span class="n">saytodo</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">,</span> <span class="n">todoos</span><span class="p">)</span>

<span class="k">def</span> <span class="nf">handle_chantodo2</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot; set todo item for channel. &quot;&quot;&quot;</span>

    <span class="n">what</span> <span class="o">=</span> <span class="n">ievent</span><span class="o">.</span><span class="n">rest</span>
    <span class="n">ttime</span> <span class="o">=</span> <span class="n">strtotime</span><span class="p">(</span><span class="n">what</span><span class="p">)</span>
    <span class="n">nr</span> <span class="o">=</span> <span class="mf">0</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">ttime</span>  <span class="o">==</span> <span class="bp">None</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;time detected &#39;</span> <span class="o">+</span> <span class="n">time</span><span class="o">.</span><span class="n">ctime</span><span class="p">(</span><span class="n">ttime</span><span class="p">))</span>
        <span class="n">what</span> <span class="o">=</span> <span class="n">striptime</span><span class="p">(</span><span class="n">what</span><span class="p">)</span>
        <span class="n">nr</span> <span class="o">=</span> <span class="n">todo</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">ievent</span><span class="o">.</span><span class="n">channel</span><span class="p">,</span> <span class="n">what</span><span class="p">,</span> <span class="n">ttime</span><span class="p">)</span>
        <span class="n">result</span> <span class="o">=</span> <span class="s">&#39;#</span><span class="si">%s</span><span class="s"> (</span><span class="si">%s</span><span class="s">) </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">nr</span><span class="p">,</span> <span class="n">ievent</span><span class="o">.</span><span class="n">nick</span><span class="p">,</span> <span class="n">what</span><span class="p">)</span>
        <span class="n">alarmnr</span> <span class="o">=</span> <span class="n">alarms</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">bot</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">ievent</span><span class="o">.</span><span class="n">channel</span><span class="p">,</span> <span class="n">ttime</span><span class="p">,</span> <span class="n">result</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="n">result</span> <span class="o">=</span> <span class="s">&#39;(</span><span class="si">%s</span><span class="s">) &#39;</span> <span class="o">%</span> <span class="n">ievent</span><span class="o">.</span><span class="n">nick</span> <span class="o">+</span> <span class="n">what</span>
        <span class="n">nr</span> <span class="o">=</span> <span class="n">todo</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">ievent</span><span class="o">.</span><span class="n">channel</span><span class="p">,</span> <span class="n">result</span><span class="p">,</span> <span class="mf">0</span><span class="p">)</span>

    <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;todo item </span><span class="si">%s</span><span class="s"> added&#39;</span> <span class="o">%</span> <span class="n">nr</span><span class="p">)</span>

<span class="n">cmnds</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo-chan&#39;</span><span class="p">,</span> <span class="n">handle_chantodo</span><span class="p">,</span> <span class="s">&#39;USER&#39;</span><span class="p">)</span>
<span class="n">examples</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo-chan&#39;</span><span class="p">,</span> <span class="s">&#39;todo-chan [&lt;item&gt;] .. add channel todo&#39;</span><span class="p">,</span> \
<span class="s">&#39;todo-chan fix bla&#39;</span><span class="p">)</span>
<span class="n">aliasset</span><span class="p">(</span><span class="s">&#39;chantodo&#39;</span><span class="p">,</span> <span class="s">&#39;todo-chan&#39;</span><span class="p">)</span>
<span class="c">#tests.add(&#39;todo-chan program the bot&#39;, &#39;todo item (\d+) added&#39;).add(&#39;todo-chan&#39;, &#39;program the bot&#39;)</span>

<span class="k">def</span> <span class="nf">handle_todochandone</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot; todo-chandone &lt;listofnrs&gt; .. remove channel todo item. &quot;&quot;&quot;</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">ievent</span><span class="o">.</span><span class="n">rest</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">missing</span><span class="p">(</span><span class="s">&#39;&lt;list of nrs&gt;&#39;</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="n">data</span> <span class="o">=</span> <span class="n">ievent</span><span class="o">.</span><span class="n">rest</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>

    <span class="k">try</span><span class="p">:</span>
        <span class="n">nrs</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
            <span class="n">nrs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">i</span><span class="p">))</span>
    <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> is not an integer&#39;</span> <span class="o">%</span> <span class="n">i</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="n">nrdone</span> <span class="o">=</span> <span class="mf">0</span>
    <span class="n">failed</span> <span class="o">=</span> <span class="p">[]</span>

    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">nrs</span><span class="p">:</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">todo</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="n">ievent</span><span class="o">.</span><span class="n">channel</span><span class="p">,</span> <span class="n">i</span><span class="p">):</span>
                <span class="n">nrdone</span> <span class="o">+=</span> <span class="mf">1</span>
        <span class="k">except</span> <span class="ne">Exception</span><span class="p">,</span> <span class="n">ex</span><span class="p">:</span>
            <span class="n">failed</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">))</span>
            <span class="n">handle_exception</span><span class="p">()</span>

    <span class="k">if</span> <span class="n">failed</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;failed to delete: &#39;</span><span class="p">,</span> <span class="n">failed</span><span class="p">)</span>

    <span class="k">if</span> <span class="n">nrdone</span> <span class="o">==</span> <span class="mf">1</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> item deleted&#39;</span> <span class="o">%</span> <span class="n">nrdone</span><span class="p">)</span>
    <span class="k">elif</span> <span class="n">nrdone</span> <span class="o">==</span> <span class="mf">0</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;no items deleted&#39;</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> items deleted&#39;</span> <span class="o">%</span> <span class="n">nrdone</span><span class="p">)</span>

<span class="n">cmnds</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo-chandone&#39;</span><span class="p">,</span> <span class="n">handle_todochandone</span><span class="p">,</span> <span class="s">&#39;USER&#39;</span><span class="p">)</span>
<span class="n">examples</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo-chandone&#39;</span><span class="p">,</span> <span class="s">&#39;todo-chandone &lt;listofnrs&gt; .. remove item </span><span class="se">\</span>
<span class="s">from channel todo list&#39;</span><span class="p">,</span> <span class="s">&#39;todo-chandone 2&#39;</span><span class="p">)</span>
<span class="n">aliasset</span><span class="p">(</span><span class="s">&#39;chandone&#39;</span><span class="p">,</span> <span class="s">&#39;todo-chandone&#39;</span><span class="p">)</span>
<span class="c">#tests.add(&#39;todo-chan program the bot&#39;, &#39;todo item (\d+) added&#39;).add(&#39;todo-chandone %s&#39;, &#39;(\d+) item deleted&#39;)</span>

<span class="k">def</span> <span class="nf">handle_settodo</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot; todo-set &lt;name&gt; &lt;txt&gt; .. add a todo to another user&#39;s todo list. &quot;&quot;&quot;</span>

    <span class="k">try</span><span class="p">:</span>
        <span class="n">who</span> <span class="o">=</span> <span class="n">ievent</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span>
        <span class="n">what</span> <span class="o">=</span> <span class="s">&#39; &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">ievent</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="mf">1</span><span class="p">:])</span>
    <span class="k">except</span> <span class="ne">IndexError</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">missing</span><span class="p">(</span><span class="s">&#39;&lt;nick&gt; &lt;what&gt;&#39;</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">what</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">missing</span><span class="p">(</span><span class="s">&#39;&lt;nick&gt; &lt;what&gt;&#39;</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="n">userhost</span> <span class="o">=</span> <span class="n">who</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">userhost</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&quot;can&#39;t find userhost for </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="n">who</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="n">whouser</span> <span class="o">=</span> <span class="n">userhost</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">whouser</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&quot;can&#39;t find user for </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="n">userhost</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="n">name</span> <span class="o">=</span> <span class="n">ievent</span><span class="o">.</span><span class="n">auth</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">name</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&quot;can&#39;t find username for </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="n">ievent</span><span class="o">.</span><span class="n">userhost</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="n">what</span> <span class="o">=</span> <span class="s">&quot;</span><span class="si">%s</span><span class="s">: </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">ievent</span><span class="o">.</span><span class="n">nick</span><span class="p">,</span> <span class="n">what</span><span class="p">)</span>
    <span class="n">ttime</span> <span class="o">=</span> <span class="n">strtotime</span><span class="p">(</span><span class="n">what</span><span class="p">)</span>
    <span class="n">nr</span> <span class="o">=</span> <span class="mf">0</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">ttime</span>  <span class="o">==</span> <span class="bp">None</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;time detected &#39;</span> <span class="o">+</span> <span class="n">time</span><span class="o">.</span><span class="n">ctime</span><span class="p">(</span><span class="n">ttime</span><span class="p">))</span>
        <span class="n">what</span> <span class="o">=</span> <span class="n">striptime</span><span class="p">(</span><span class="n">what</span><span class="p">)</span>
        <span class="n">nr</span> <span class="o">=</span> <span class="n">todo</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">whouser</span><span class="p">,</span> <span class="n">what</span><span class="p">,</span> <span class="n">ttime</span><span class="p">)</span>
        <span class="n">what</span> <span class="o">=</span> <span class="s">&quot;#</span><span class="si">%s</span><span class="s"> </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">nr</span><span class="p">,</span> <span class="n">what</span><span class="p">)</span>
        <span class="n">alarmnr</span> <span class="o">=</span> <span class="n">alarms</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">bot</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">who</span><span class="p">,</span> <span class="n">ttime</span><span class="p">,</span> <span class="n">what</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="n">nr</span> <span class="o">=</span> <span class="n">todo</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">whouser</span><span class="p">,</span> <span class="n">what</span><span class="p">,</span> <span class="mf">0</span><span class="p">)</span>

    <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;todo item </span><span class="si">%s</span><span class="s"> added&#39;</span> <span class="o">%</span> <span class="n">nr</span><span class="p">)</span>

<span class="n">cmnds</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo-set&#39;</span><span class="p">,</span> <span class="n">handle_settodo</span><span class="p">,</span> <span class="s">&#39;USER&#39;</span><span class="p">)</span>
<span class="n">examples</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo-set&#39;</span><span class="p">,</span> <span class="s">&#39;todo-set &lt;nick&gt; &lt;txt&gt; .. set todo item of </span><span class="se">\</span>
<span class="s">&lt;nick&gt;&#39;</span><span class="p">,</span> <span class="s">&#39;todo-set dunker bot proggen&#39;</span><span class="p">)</span>
<span class="c">#tests.add(&#39;user-addpermit owner todo&#39;).add(&#39;todo-set {{ me }} program the bot&#39;, &#39;todo item (\d+) added&#39;)</span>

<span class="k">def</span> <span class="nf">handle_gettodo</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot; todo-get &lt;nick&gt; .. get todo of another user. &quot;&quot;&quot;</span>

    <span class="k">try</span><span class="p">:</span>
        <span class="n">who</span> <span class="o">=</span> <span class="n">ievent</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span>
    <span class="k">except</span> <span class="ne">IndexError</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">missing</span><span class="p">(</span><span class="s">&#39;&lt;nick&gt;&#39;</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="n">whouser</span> <span class="o">=</span> <span class="n">userhost</span> <span class="o">=</span> <span class="n">who</span>
    <span class="n">name</span> <span class="o">=</span> <span class="n">ievent</span><span class="o">.</span><span class="n">auth</span>
    <span class="n">todoos</span> <span class="o">=</span> <span class="n">todo</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">whouser</span><span class="p">)</span>
    <span class="n">saytodo</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">,</span> <span class="n">todoos</span><span class="p">)</span>

<span class="n">cmnds</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo-get&#39;</span><span class="p">,</span> <span class="n">handle_gettodo</span><span class="p">,</span> <span class="p">[</span><span class="s">&#39;USER&#39;</span><span class="p">,</span> <span class="s">&#39;WEB&#39;</span><span class="p">])</span>
<span class="n">examples</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo-get&#39;</span><span class="p">,</span> <span class="s">&#39;todo-get &lt;nick&gt; .. get the todo list of </span><span class="se">\</span>
<span class="s">&lt;nick&gt;&#39;</span><span class="p">,</span> <span class="s">&#39;todo-get dunker&#39;</span><span class="p">)</span>
<span class="c">#tests.add(&#39;todo program the bot&#39;).add(&#39;todo-get {{ me }}&#39;, &#39;program the bot&#39;)</span>

<span class="k">def</span> <span class="nf">handle_todotime</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot; todo-time .. show time related todoos. &quot;&quot;&quot;</span>

    <span class="n">name</span> <span class="o">=</span> <span class="n">ievent</span><span class="o">.</span><span class="n">auth</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">name</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&quot;can&#39;t find username for </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="n">ievent</span><span class="o">.</span><span class="n">userhost</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="n">todoos</span> <span class="o">=</span> <span class="n">todo</span><span class="o">.</span><span class="n">timetodo</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>
    <span class="n">saytodo</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">,</span> <span class="n">todoos</span><span class="p">)</span>

<span class="n">cmnds</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo-time&#39;</span><span class="p">,</span> <span class="n">handle_todotime</span><span class="p">,</span> <span class="s">&#39;USER&#39;</span><span class="p">)</span>
<span class="n">examples</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo-time&#39;</span><span class="p">,</span> <span class="s">&#39;todo-time .. show todo items with time fields&#39;</span><span class="p">,</span> \
<span class="s">&#39;todo-time&#39;</span><span class="p">)</span>
<span class="n">aliasset</span><span class="p">(</span><span class="s">&#39;tt&#39;</span><span class="p">,</span> <span class="s">&#39;todo-time&#39;</span><span class="p">)</span>
<span class="c">#tests.add(&#39;todo 11-11-2011 test&#39;, &#39;time detected&#39;).add(&#39;todo-time&#39;, &#39;test&#39;)</span>

<span class="k">def</span> <span class="nf">handle_todoweek</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot; todo-week .. show time related todo items for this week. &quot;&quot;&quot;</span>

    <span class="n">name</span> <span class="o">=</span> <span class="n">ievent</span><span class="o">.</span><span class="n">auth</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">name</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&quot;can&#39;t find username for </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="n">ievent</span><span class="o">.</span><span class="n">userhost</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="n">todoos</span> <span class="o">=</span> <span class="n">todo</span><span class="o">.</span><span class="n">withintime</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">today</span><span class="p">(),</span> <span class="n">today</span><span class="p">()</span><span class="o">+</span><span class="mf">7</span><span class="o">*</span><span class="mf">24</span><span class="o">*</span><span class="mf">60</span><span class="o">*</span><span class="mf">60</span><span class="p">)</span>
    <span class="n">saytodo</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">,</span> <span class="n">todoos</span><span class="p">)</span>

<span class="n">cmnds</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo-week&#39;</span><span class="p">,</span> <span class="n">handle_todoweek</span><span class="p">,</span> <span class="s">&#39;USER&#39;</span><span class="p">)</span>
<span class="n">examples</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo-week&#39;</span><span class="p">,</span> <span class="s">&#39;todo-week .. todo items for this week&#39;</span><span class="p">,</span> <span class="s">&#39;todo-week&#39;</span><span class="p">)</span>
<span class="c">#tests.add(&#39;tomorrow test the bot&#39;).add(&#39;todo-week&#39;, &#39;test the bot&#39;)</span>

<span class="k">def</span> <span class="nf">handle_today</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot; todo-today .. show time related todo items for today. &quot;&quot;&quot;</span>

    <span class="n">name</span> <span class="o">=</span> <span class="n">ievent</span><span class="o">.</span><span class="n">auth</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">name</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&quot;can&#39;t find username for </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="n">ievent</span><span class="o">.</span><span class="n">userhost</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="n">todoos</span> <span class="o">=</span> <span class="n">todo</span><span class="o">.</span><span class="n">withintime</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">today</span><span class="p">(),</span> <span class="n">today</span><span class="p">()</span><span class="o">+</span><span class="mf">24</span><span class="o">*</span><span class="mf">60</span><span class="o">*</span><span class="mf">60</span><span class="p">)</span>
    <span class="n">saytodo</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">,</span> <span class="n">todoos</span><span class="p">)</span>

<span class="n">cmnds</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo-today&#39;</span><span class="p">,</span> <span class="n">handle_today</span><span class="p">,</span> <span class="s">&#39;USER&#39;</span><span class="p">)</span>
<span class="n">examples</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo-today&#39;</span><span class="p">,</span> <span class="s">&#39;todo-today .. todo items for today&#39;</span><span class="p">,</span> <span class="s">&#39;todo-today&#39;</span><span class="p">)</span>
<span class="n">aliasset</span><span class="p">(</span><span class="s">&#39;today&#39;</span><span class="p">,</span> <span class="s">&#39;todo-today&#39;</span><span class="p">)</span>
<span class="c">#tests.add(&#39;todo test the bot&#39;).add(&#39;todo-today&#39;, &#39;test the bot&#39;)</span>

<span class="k">def</span> <span class="nf">handle_tomorrow</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot; todo-tomorrow .. show time related todo items for tomorrow. &quot;&quot;&quot;</span>

    <span class="n">username</span> <span class="o">=</span> <span class="n">ievent</span><span class="o">.</span><span class="n">auth</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">username</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&quot;can&#39;t find username for </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="n">ievent</span><span class="o">.</span><span class="n">userhost</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="k">if</span> <span class="n">ievent</span><span class="o">.</span><span class="n">rest</span><span class="p">:</span>
        <span class="n">what</span> <span class="o">=</span> <span class="n">ievent</span><span class="o">.</span><span class="n">rest</span>
        <span class="n">ttime</span> <span class="o">=</span> <span class="n">strtotime</span><span class="p">(</span><span class="n">what</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">ttime</span> <span class="o">!=</span> <span class="bp">None</span><span class="p">:</span>

            <span class="k">if</span> <span class="n">ttime</span> <span class="o">&lt;</span> <span class="n">today</span><span class="p">()</span> <span class="ow">or</span> <span class="n">ttime</span> <span class="o">&gt;</span> <span class="n">today</span><span class="p">()</span> <span class="o">+</span> <span class="mf">24</span><span class="o">*</span><span class="mf">60</span><span class="o">*</span><span class="mf">60</span><span class="p">:</span>
                <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%s</span><span class="s"> is not tomorrow&quot;</span> <span class="o">%</span> \
<span class="n">time</span><span class="o">.</span><span class="n">ctime</span><span class="p">(</span><span class="n">ttime</span> <span class="o">+</span> <span class="mf">24</span><span class="o">*</span><span class="mf">60</span><span class="o">*</span><span class="mf">60</span><span class="p">))</span>
                <span class="k">return</span>

            <span class="n">ttime</span> <span class="o">+=</span> <span class="mf">24</span><span class="o">*</span><span class="mf">60</span><span class="o">*</span><span class="mf">60</span>
            <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;time detected &#39;</span> <span class="o">+</span> <span class="n">time</span><span class="o">.</span><span class="n">ctime</span><span class="p">(</span><span class="n">ttime</span><span class="p">))</span>
            <span class="n">what</span> <span class="o">=</span> <span class="n">striptime</span><span class="p">(</span><span class="n">what</span><span class="p">)</span>

        <span class="k">else</span><span class="p">:</span>
            <span class="n">ttime</span> <span class="o">=</span> <span class="n">today</span><span class="p">()</span> <span class="o">+</span> <span class="mf">42</span><span class="o">*</span><span class="mf">60</span><span class="o">*</span><span class="mf">60</span>

        <span class="n">todo</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">username</span><span class="p">,</span> <span class="n">what</span><span class="p">,</span> <span class="n">ttime</span><span class="p">)</span>   
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;todo added&#39;</span><span class="p">)</span>    
        <span class="k">return</span>

    <span class="n">todoos</span> <span class="o">=</span> <span class="n">todo</span><span class="o">.</span><span class="n">withintime</span><span class="p">(</span><span class="n">username</span><span class="p">,</span> <span class="n">today</span><span class="p">()</span><span class="o">+</span><span class="mf">24</span><span class="o">*</span><span class="mf">60</span><span class="o">*</span><span class="mf">60</span><span class="p">,</span> <span class="n">today</span><span class="p">()</span><span class="o">+</span><span class="mf">2</span><span class="o">*</span><span class="mf">24</span><span class="o">*</span><span class="mf">60</span><span class="o">*</span><span class="mf">60</span><span class="p">)</span>
    <span class="n">saytodo</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">,</span> <span class="n">todoos</span><span class="p">)</span>

<span class="n">cmnds</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo-tomorrow&#39;</span><span class="p">,</span> <span class="n">handle_tomorrow</span><span class="p">,</span> <span class="s">&#39;USER&#39;</span><span class="p">)</span>
<span class="n">examples</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo-tomorrow&#39;</span><span class="p">,</span> <span class="s">&#39;todo-tomorrow .. todo items for tomorrow&#39;</span><span class="p">,</span> \
<span class="s">&#39;todo-tomorrow&#39;</span><span class="p">)</span>
<span class="n">aliasset</span><span class="p">(</span><span class="s">&#39;tomorrow&#39;</span><span class="p">,</span> <span class="s">&#39;todo-tomorrow&#39;</span><span class="p">)</span>
<span class="c">#tests.add(&#39;todo-tomorrow test the bot&#39;).add(&#39;todo-time&#39;, &#39;test the bot&#39;)</span>

<span class="k">def</span> <span class="nf">handle_setpriority</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        todo-setprio [&lt;channel|name&gt;] &lt;itemnr&gt; &lt;prio&gt; .. show priority \</span>
<span class="sd">        on todo item.</span>

<span class="sd">     &quot;&quot;&quot;</span>

    <span class="k">try</span><span class="p">:</span>
        <span class="p">(</span><span class="n">who</span><span class="p">,</span> <span class="n">itemnr</span><span class="p">,</span> <span class="n">prio</span><span class="p">)</span> <span class="o">=</span> <span class="n">ievent</span><span class="o">.</span><span class="n">args</span>
    <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="p">(</span><span class="n">itemnr</span><span class="p">,</span> <span class="n">prio</span><span class="p">)</span> <span class="o">=</span> <span class="n">ievent</span><span class="o">.</span><span class="n">args</span>
            <span class="n">who</span> <span class="o">=</span> <span class="n">ievent</span><span class="o">.</span><span class="n">auth</span>
        <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
            <span class="n">ievent</span><span class="o">.</span><span class="n">missing</span><span class="p">(</span><span class="s">&#39;[&lt;channe|namel&gt;] &lt;itemnr&gt; &lt;priority&gt;&#39;</span><span class="p">)</span>
            <span class="k">return</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">who</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&quot;can&#39;t find username for </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="n">ievent</span><span class="o">.</span><span class="n">userhost</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="k">try</span><span class="p">:</span>
        <span class="n">itemnr</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">itemnr</span><span class="p">)</span>
        <span class="n">prio</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">prio</span><span class="p">)</span>
    <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">missing</span><span class="p">(</span><span class="s">&#39;[&lt;channel|name&gt;] &lt;itemnr&gt; &lt;priority&gt;&#39;</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="n">who</span> <span class="o">=</span> <span class="n">who</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span>
    <span class="n">todo</span><span class="o">.</span><span class="n">setprio</span><span class="p">(</span><span class="n">who</span><span class="p">,</span> <span class="n">itemnr</span><span class="p">,</span> <span class="n">prio</span><span class="p">)</span>
    <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;priority set&#39;</span><span class="p">)</span>

<span class="n">cmnds</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo-setprio&#39;</span><span class="p">,</span> <span class="n">handle_setpriority</span><span class="p">,</span> <span class="s">&#39;USER&#39;</span><span class="p">)</span>
<span class="n">examples</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo-setprio&#39;</span><span class="p">,</span> <span class="s">&#39;todo-setprio [&lt;channel|name&gt;] &lt;itemnr&gt; &lt;prio&gt; </span><span class="se">\</span>
<span class="s">.. set todo priority&#39;</span><span class="p">,</span> <span class="s">&#39;1) todo-setprio #dunkbots 2 5 2) todo-setprio owner </span><span class="se">\</span>
<span class="s">3 10 3) todo-setprio 2 10&#39;</span><span class="p">)</span>
<span class="n">aliasset</span><span class="p">(</span><span class="s">&#39;setprio&#39;</span><span class="p">,</span> <span class="s">&#39;todo-setprio&#39;</span><span class="p">)</span>
<span class="c">#tests.add(&#39;todo test the bot&#39;, &#39;todo item (\d+) added&#39;).add(&#39;todo-setprio %s 10&#39;, &#39;priority set&#39;)</span>

<span class="k">def</span> <span class="nf">handle_todosettime</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot; </span>
<span class="sd">        todo-settime [&lt;channel|name&gt;] &lt;itemnr&gt; &lt;timestring&gt; .. set time \</span>
<span class="sd">        on todo item.</span>

<span class="sd">     &quot;&quot;&quot;</span>

    <span class="n">ttime</span> <span class="o">=</span> <span class="n">strtotime</span><span class="p">(</span><span class="n">ievent</span><span class="o">.</span><span class="n">rest</span><span class="p">)</span>

    <span class="k">if</span> <span class="n">ttime</span> <span class="o">==</span> <span class="bp">None</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&quot;can&#39;t detect time&quot;</span><span class="p">)</span>
        <span class="k">return</span>   

    <span class="n">txt</span> <span class="o">=</span> <span class="n">striptime</span><span class="p">(</span><span class="n">ievent</span><span class="o">.</span><span class="n">rest</span><span class="p">)</span>

    <span class="k">try</span><span class="p">:</span>
        <span class="p">(</span><span class="n">who</span><span class="p">,</span> <span class="n">itemnr</span><span class="p">)</span> <span class="o">=</span> <span class="n">txt</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
    <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="p">(</span><span class="n">itemnr</span><span class="p">,</span> <span class="p">)</span> <span class="o">=</span> <span class="n">txt</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
            <span class="n">who</span> <span class="o">=</span> <span class="n">ievent</span><span class="o">.</span><span class="n">auth</span>
        <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
            <span class="n">ievent</span><span class="o">.</span><span class="n">missing</span><span class="p">(</span><span class="s">&#39;[&lt;channel|name&gt;] &lt;itemnr&gt; &lt;timestring&gt;&#39;</span><span class="p">)</span>
            <span class="k">return</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">who</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&quot;can&#39;t find username for </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="n">ievent</span><span class="o">.</span><span class="n">userhost</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="k">try</span><span class="p">:</span>
        <span class="n">itemnr</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">itemnr</span><span class="p">)</span>
    <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">missing</span><span class="p">(</span><span class="s">&#39;[&lt;channel|name&gt;] &lt;itemnr&gt; &lt;timestring&gt;&#39;</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="n">who</span> <span class="o">=</span> <span class="n">who</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">todo</span><span class="o">.</span><span class="n">settime</span><span class="p">(</span><span class="n">who</span><span class="p">,</span> <span class="n">itemnr</span><span class="p">,</span> <span class="n">ttime</span><span class="p">):</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;no todo </span><span class="si">%s</span><span class="s"> found for </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">itemnr</span><span class="p">,</span> <span class="n">who</span><span class="p">))</span>
        <span class="k">return</span>

    <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;time of todo </span><span class="si">%s</span><span class="s"> set to </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">itemnr</span><span class="p">,</span> <span class="n">time</span><span class="o">.</span><span class="n">ctime</span><span class="p">(</span><span class="n">ttime</span><span class="p">)))</span>

<span class="n">cmnds</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo-settime&#39;</span><span class="p">,</span> <span class="n">handle_todosettime</span><span class="p">,</span> <span class="s">&#39;USER&#39;</span><span class="p">)</span>
<span class="n">examples</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo-settime&#39;</span><span class="p">,</span> <span class="s">&#39;todo-settime [&lt;channel|name&gt;] &lt;itemnr&gt; </span><span class="se">\</span>
<span class="s">&lt;timestring&gt; .. set todo time&#39;</span><span class="p">,</span> <span class="s">&#39;1) todo-settime #dunkbots 2 13:00 2) </span><span class="se">\</span>
<span class="s">todo-settime owner 3 2-2-2010 3) todo-settime 2 22:00&#39;</span><span class="p">)</span>
<span class="c">#tests.add(&#39;todo test the bot&#39;, &#39;todo item (\d+) added&#39;).add(&#39;todo-settime %s 11:00&#39;, &#39;time of todo %s set&#39;)</span>

<span class="k">def</span> <span class="nf">handle_getpriority</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        todo-getprio &lt;[channel|name]&gt; &lt;itemnr&gt; .. get priority of todo \</span>
<span class="sd">        item.</span>

<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">try</span><span class="p">:</span>
        <span class="p">(</span><span class="n">who</span><span class="p">,</span> <span class="n">itemnr</span><span class="p">)</span> <span class="o">=</span> <span class="n">ievent</span><span class="o">.</span><span class="n">args</span>
    <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="n">itemnr</span> <span class="o">=</span> <span class="n">ievent</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span>
            <span class="n">who</span> <span class="o">=</span> <span class="n">ievent</span><span class="o">.</span><span class="n">auth</span>
        <span class="k">except</span> <span class="ne">IndexError</span><span class="p">:</span>
            <span class="n">ievent</span><span class="o">.</span><span class="n">missing</span><span class="p">(</span><span class="s">&#39;[&lt;channel|name&gt;] &lt;itemnr&gt;&#39;</span><span class="p">)</span>
            <span class="k">return</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">who</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&quot;can&#39;t find username for </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="n">ievent</span><span class="o">.</span><span class="n">userhost</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="k">try</span><span class="p">:</span>
        <span class="n">itemnr</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">itemnr</span><span class="p">)</span>
    <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">missing</span><span class="p">(</span><span class="s">&#39;[&lt;channel|name&gt;] &lt;itemnr&gt;&#39;</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="n">who</span> <span class="o">=</span> <span class="n">who</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span>
    <span class="n">prio</span> <span class="o">=</span> <span class="n">todo</span><span class="o">.</span><span class="n">getprio</span><span class="p">(</span><span class="n">who</span><span class="p">,</span> <span class="n">itemnr</span><span class="p">)</span>
    <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;priority is </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">prio</span><span class="p">)</span>

<span class="n">cmnds</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo-getprio&#39;</span><span class="p">,</span> <span class="n">handle_getpriority</span><span class="p">,</span> <span class="s">&#39;USER&#39;</span><span class="p">)</span>
<span class="n">examples</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;todo-getprio&#39;</span><span class="p">,</span> <span class="s">&#39;todo-getprio [&lt;channel|name&gt;] &lt;itemnr&gt; .. get </span><span class="se">\</span>
<span class="s">todo priority&#39;</span><span class="p">,</span> <span class="s">&#39;1) todo-getprio #dunkbots 5 2) todo-getprio 3&#39;</span><span class="p">)</span>
<span class="n">aliasset</span><span class="p">(</span><span class="s">&#39;prio&#39;</span><span class="p">,</span> <span class="s">&#39;todo-getprio&#39;</span><span class="p">)</span>
<span class="c">#tests.add(&#39;todo test the bot&#39;, &#39;todo item (\d+) added&#39;).add(&#39;todo-getprio %s&#39;, &#39;priority is 0&#39;)</span>

<span class="k">def</span> <span class="nf">saytodo</span><span class="p">(</span><span class="n">bot</span><span class="p">,</span> <span class="n">ievent</span><span class="p">,</span> <span class="n">todoos</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot; output todo items of &lt;name&gt;. &quot;&quot;&quot;</span>

    <span class="n">result</span> <span class="o">=</span> <span class="p">[]</span>
    <span class="n">now</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">todoos</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&#39;nothing todo ;]&#39;</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="n">counter</span> <span class="o">=</span> <span class="mf">0</span>

    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">todoos</span><span class="p">:</span>
        <span class="n">counter</span> <span class="o">+=</span> <span class="mf">1</span>
        <span class="n">res</span> <span class="o">=</span> <span class="s">&quot;&quot;</span>
        <span class="n">res</span> <span class="o">+=</span> <span class="s">&quot;</span><span class="si">%s</span><span class="s"> - &quot;</span> <span class="o">%</span> <span class="n">i</span><span class="o">.</span><span class="n">key</span><span class="p">()</span><span class="o">.</span><span class="n">id</span><span class="p">()</span>

        <span class="k">if</span> <span class="n">i</span><span class="o">.</span><span class="n">priority</span><span class="p">:</span>
            <span class="n">res</span> <span class="o">+=</span> <span class="s">&quot;[</span><span class="si">%s</span><span class="s">] &quot;</span> <span class="o">%</span> <span class="n">i</span><span class="o">.</span><span class="n">priority</span>

        <span class="k">if</span> <span class="n">i</span><span class="o">.</span><span class="n">time</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">i</span><span class="o">.</span><span class="n">time</span> <span class="o">==</span> <span class="n">i</span><span class="o">.</span><span class="n">time</span><span class="o">.</span><span class="n">min</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">i</span><span class="o">.</span><span class="n">time</span> <span class="o">&lt;</span> <span class="n">now</span><span class="p">:</span>
                <span class="n">res</span> <span class="o">+=</span> <span class="s">&#39;TOO LATE: &#39;</span>
            <span class="n">res</span> <span class="o">+=</span> <span class="s">&quot;</span><span class="si">%s</span><span class="s"> </span><span class="si">%s</span><span class="s"> &quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">i</span><span class="o">.</span><span class="n">time</span><span class="o">.</span><span class="n">ctime</span><span class="p">(),</span> <span class="n">i</span><span class="o">.</span><span class="n">descr</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">res</span> <span class="o">+=</span> <span class="s">&quot;</span><span class="si">%s</span><span class="s"> &quot;</span> <span class="o">%</span> <span class="n">i</span><span class="o">.</span><span class="n">descr</span>

        <span class="n">result</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">res</span><span class="o">.</span><span class="n">strip</span><span class="p">())</span>

    <span class="k">if</span> <span class="n">result</span><span class="p">:</span>
        <span class="n">ievent</span><span class="o">.</span><span class="n">reply</span><span class="p">(</span><span class="s">&quot;todo: &quot;</span><span class="p">,</span> <span class="n">result</span><span class="p">)</span>
</pre></div>
</td></tr></table></div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h3><a href="../index.html">Table Of Contents</a></h3>
            <ul>
<li><a class="reference external" href="">todo</a><ul>
<li><a class="reference external" href="#module-waveplugs.todo">description</a></li>
<li><a class="reference external" href="#code">code</a></li>
</ul>
</li>
</ul>

            <h4>Previous topic</h4>
            <p class="topless"><a href="rss.html"
                                  title="previous chapter">rss</a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="wikipedia.html"
                                  title="next chapter">wikipedia</a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="../_sources/waveplugs/todo.txt"
                     rel="nofollow">Show Source</a></li>
            </ul>
          <div id="searchbox" style="display: none">
            <h3>Quick search</h3>
              <form class="search" action="../search.html" method="get">
                <input type="text" name="q" size="18" />
                <input type="submit" value="Go" />
                <input type="hidden" name="check_keywords" value="yes" />
                <input type="hidden" name="area" value="default" />
              </form>
              <p class="searchtip" style="font-size: 90%">
              Enter search terms or a module, class or function name.
              </p>
          </div>
          <script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../modindex.html" title="Global Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="wikipedia.html" title="wikipedia"
             >next</a> |</li>
        <li class="right" >
          <a href="rss.html" title="rss"
             >previous</a> |</li>
        <li><a href="../index.html">GOZERWAVE v0.1 BETA documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
      &copy; Copyright 2009, Bart Thate.
      Last updated on Nov 14, 2009.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.3.
    </div>
  </body>
</html>